
public class cTestPlayer {
	private static int startingChips;
	private static int numberOfFailedTests;
	public static void main(String[] args) {
		numberOfFailedTests = 0;
		startingChips = 100;
		cPlayer testPlayer = new cPlayer(startingChips);
		
		/* Testing getChipAmount() */
		System.out.println("Testing cPlayer.getChipAmount()");
		System.out.println("Chip amount should be " + startingChips);
		int playersChips = testPlayer.getChipAmount();
		System.out.println("Player's chips = " + playersChips);
		if(playersChips == startingChips){
			System.out.println("Passed Test");
		}
		else{
			System.out.println("Failed Test");
			numberOfFailedTests++;
		}
		System.out.println("");
		
		/* Testing setChips */
		int newChipAmount = 50;
		System.out.println("Testing cPlayer.setChips(int amount)");
		System.out.println("Starting chip amount is " + testPlayer.getChipAmount());
		System.out.println("Called setChips(int chips). New chip amount should be "+newChipAmount);
		testPlayer.setChips(newChipAmount);
		playersChips = testPlayer.getChipAmount();
		System.out.println("Player's chips = " + playersChips);
		if(playersChips == newChipAmount){
			System.out.println("Passed Test");
		}
		else{
			System.out.println("Failed Test");
			numberOfFailedTests++;
		}
		System.out.println("");
		
		
		/* Testing takeChips */
		int betAmount = 25;
		int startingChips;
		System.out.println("Testing cPlayer.takeChips(int amount)");
		startingChips = testPlayer.getChipAmount();
		System.out.println("Starting chip amount is " + startingChips);
		System.out.println("Called takeChips(int chips). New chip amount should be "+ (startingChips - betAmount));
		testPlayer.takeChips(betAmount);
		playersChips = testPlayer.getChipAmount();
		System.out.println("Player's chips = " + playersChips);
		if(playersChips == startingChips - betAmount){
			System.out.println("Passed Test");
		}
		else{
			System.out.println("Failed Test");
			numberOfFailedTests++;
		}
		System.out.println("");
		
		/* Testing getting chips in hand and round */
		betAmount = 10;
		startingChips = 100;
		testPlayer.resetChipsInHand();
		testPlayer.resetChipsInRound();
		testPlayer.setChips(startingChips);
		
		System.out.println("Testing cPlayer.resetChipsInRound() and cPlayer.resetChipsInHand()");
		startingChips = testPlayer.getChipAmount();
		System.out.println("Starting chip amount is " + startingChips);
		
		//simulate round 1 betting
		System.out.println("Simulating first round of betting with 2 bets of " + betAmount + " for a total bet of " + (2*betAmount));
		testPlayer.takeChips(betAmount);
		testPlayer.takeChips(betAmount);
		System.out.println("Player's chips after round 1 = " + (startingChips - (2*betAmount)));
		System.out.println("Calling cPlayer.resetChipsInRound().  Player's chips in round should now be 0");
		testPlayer.resetChipsInRound();
		if(testPlayer.getChipsInRound() == 0){
			System.out.println("Player's chips in the round = 0");
			System.out.println("Passed");
		}
		else{
			System.out.println("Failed");
			numberOfFailedTests++;
		}
		System.out.println("");
		
		//simulate round 2 betting
		System.out.println("Simulating second round of betting with 3 bets of " + betAmount + " for a total bet of " + (3*betAmount));
		System.out.println("");
		startingChips = testPlayer.getChipAmount();
		testPlayer.takeChips(betAmount);
		testPlayer.takeChips(betAmount);
		testPlayer.takeChips(betAmount);
		System.out.println("Player's chips after round2 = " + testPlayer.getChipAmount());
		System.out.println("");
		System.out.println("Calling cPlayer.getChipsInRound().  Player's chips in round should now be 30");
		System.out.println("Player's chips in round = " + testPlayer.getChipsInRound());
		System.out.println("");
		System.out.println("Calling cPlayer.getChipsInHand().  Player's chips in hand should now be 50");
		System.out.println("Player's chips in hand = " + testPlayer.getChipsInHand());
		System.out.println("");
		System.out.println("Calling cPlayer.resetChipsInRound().  Player's chips in round should now be 0");
		testPlayer.resetChipsInRound();
		System.out.println("Player's chips in round = " + testPlayer.getChipsInRound());
		System.out.println("");
		System.out.println("Calling cPlayer.resetChipsInHand().  Player's chips in hand should now be 0");
		testPlayer.resetChipsInHand();
		System.out.println("Player's chips in hand = " + testPlayer.getChipsInHand());
		System.out.println("");
		
		if(testPlayer.getChipsInHand() == 0){
			System.out.println("Passed");
		}
		else{
			System.out.println("Failed");
			numberOfFailedTests++;
		}
		System.out.println("");
		
		
		/* Testing refundChips(int amount) */
		startingChips = 100;
		betAmount = 75;
		int otherPlayersMaxBet = 50;
		testPlayer.setChips(startingChips);
		testPlayer.resetChipsInHand();
		testPlayer.resetChipsInRound();
		
		System.out.println("Testing cPlayer.refundChips(int amount)");
		System.out.println("Start state: Player started with " + startingChips + " chips then bet " + betAmount + " so they"+
				" only had " + (startingChips-betAmount) + " chips left");
		System.out.println("A player then went all in with a bet of " + otherPlayersMaxBet + " so the first player should get a refund of chips");
		
		startingChips = testPlayer.getChipAmount();
		System.out.println("Starting chip amount is " + startingChips);
		testPlayer.takeChips(betAmount);
		System.out.println("After bet of "+ betAmount + " the player has " + testPlayer.getChipAmount());
		
		System.out.println("Player's chips in round = " + testPlayer.getChipsInRound());
		System.out.println("Player's chips in hand = " + testPlayer.getChipsInHand());
		System.out.println("");
		System.out.println("After the remaining players make their bets, the max bet of the others is " + otherPlayersMaxBet);
		System.out.println("The first player should then get a refund of " + (betAmount - otherPlayersMaxBet));
		
		testPlayer.refundChips(25);
		
		System.out.println("After the refund the player has " + testPlayer.getChipAmount());
		
		System.out.println("Player's chips in round = " + testPlayer.getChipsInRound());
		System.out.println("Player's chips in hand = " + testPlayer.getChipsInHand());
		
		if(testPlayer.getChipAmount() != 50){
			numberOfFailedTests++;
			System.out.println("Failed");
		}
		else{
			System.out.println("Passed");
		}
		
		
		
		
		/* Print results */
		System.out.println("");
		System.out.println("Test Results");
		System.out.println("Number of Failed Tests: " + numberOfFailedTests);
		if(numberOfFailedTests > 0){
			System.out.println("Tests Failed");
		}
		else{
			System.out.println("Tests Passed");
		}
	}
}
